﻿using Blog190311.Models;
using Blog190311.Models.DAL;
using Blog190311.Models.DBModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Blog190311.Controllers
{
    public class ShareController : Controller
    {
        // GET: Share
        public ActionResult Index(string page, string limit, string con)
        {
            if (string.IsNullOrWhiteSpace(page))
            {
                page = "1";
            }
            if (string.IsNullOrWhiteSpace(limit))
            {
                limit = "8";
            }
            PhotoService photoService = new PhotoService();
            ArticleService articleService = new ArticleService();
            List<UIData> list = photoService.GetPhotoMain(Convert.ToInt32(page), Convert.ToInt32(limit), con);
            ViewBag.total = articleService.GetCount(con);
            ViewBag.page = page;
            ViewBag.limit = limit;
            return View(list);
        }

        public ActionResult Detail(int id)
        {
            PhotoService photoService = new PhotoService();
            ArticleService articleService = new ArticleService();
            List<UIData> list = photoService.GetPhotoById(id);
            Article article = articleService.GetArticles(id);
            ViewBag.article = article;
            return View(list);
        }

    }
}